package com.interview.javabase.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author: zsg
 * @description:
 * @date: 2019/6/29 10:25
 * @modified:
 */
public class Demo2 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask task = new FutureTask(new C1());
        new Thread(task).start();

        System.out.println(task.get());
        FutureTask task1 = new FutureTask(new C2());
        new Thread(task1).start();
        System.out.println(task1.get());
    }
}

class C1 implements Callable<String> {

    @Override
    public String call() throws Exception {
        Thread.sleep(1000);
        return "C1";
    }
}


class C2 implements Callable<String> {

    @Override
    public String call() throws Exception {
        return "C2";
    }
}
class T1 extends Thread{

    @Override
    public void run() {
        System.out.println("T1#run");
    }
}

class T2 extends Thread{

    @Override
    public void run() {
        System.out.println("T2#run");
    }
}